package cn.craftyun.yunexam.mapper;

import cn.craftyun.yunexam.entity.ExamStatus;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface ExamStatusMapper extends BaseMapper<ExamStatus> {
    @Update("DELETE FROM exam_status WHERE exam_id IN (SELECT id FROM exam WHERE paper_id=#{paperId})")
    int deleteByPaperId(@Param("paperId") Long paperId);

    @Select("SELECT id,stu_number,`name`,`status`,end_time,end_score FROM `user`,`exam_status` WHERE `user`.id = exam_status.user_id and exam_status.exam_id=#{examId} order by stu_number")
    List<Map<String, Object>> getExamStatus(Long examId);
}
